﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace Pixysoft.Framework.Noebe.MemoryCaches.Core
{
    class NullCacheDataRow : ICacheDataRow
    {
        string cacheKey;
        DateTime createDate;
        DateTime endDate;
        int hitRate;

        public NullCacheDataRow(string cacheKey, int timespan)
        {
            this.cacheKey = cacheKey;

            this.CreateDate = Pixysoft.Tools.GlobalTimer.Instance.GetGlobalTime();

            if (timespan < 0)
                this.EndDate = DateTime.MaxValue;
            else
                this.EndDate = this.CreateDate.AddMilliseconds(timespan);

            this.hitRate = 0;
        }

        public string CacheKey
        {
            get { return cacheKey; }
            set { cacheKey = value; }
        }

        public DateTime CreateDate
        {
            get { return createDate; }
            set { createDate = value; }
        }

        public DateTime EndDate
        {
            get { return endDate; }
            set { endDate = value; }
        }

        public int HitRate
        {
            get { return hitRate; }
            set { hitRate = value; }
        }

        public void Hit()
        {
            hitRate++;
        }

        public void GetDataRow(System.Data.DataTable table)
        {
            // do nothing
        }
    }
}
